package com.ycq.parser.node;

import com.ycq.parser.ImageInfo;
import com.ycq.parser.QuestionNode;
import com.ycq.parser.attribute.AttributeKey;
import com.ycq.parser.attribute.AttributeNode;
import lombok.Data;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * TODO
 *
 * @author ycq
 * @date 2025/9/24 14:38
 */
@Data
public abstract class AbstractQuestionNode implements QuestionNode {

    protected String questionCode;
    protected List<String> rawLines;
    protected Map<String, AttributeNode> attributes = new HashMap<>();
    protected List<ImageInfo> images;

    @Override
    public <T> T getAttribute(AttributeKey<T> key) {
        return key.get(attributes);
    }

    @Override
    public String getRawQuestion() {
        if(rawLines == null){
            return null;
        }
        return String.join("\n", rawLines);
    }

    @Override
    public List<String> getQuestionLines() {
        return rawLines;
    }
}
